/**
 * 作者：陈文斌 on 2019/1/21.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/view/Tile/list_tile_normal.dart';
import 'package:crm/view/AppBar/custom_app_bar.dart';

const String Title = '外勤拜访详情';

class VisitorRecordDetailPage extends StatefulWidget {
  final String id;

  @override
  VisitorRecordDetailPage({
    Key key,
    this.id = '31bba2f5-c02a-4088-a53d-24576c5d120a',
  }) : super(key: key);

  State<StatefulWidget> createState() {
    return _VisitorRecordDetailPageState();
  }
}

class _VisitorRecordDetailPageState extends State<VisitorRecordDetailPage> {
  final TextStyle _listTileTitleStyle = TextStyle(
    color: AppColors.DetailTextColor,
    fontSize: AppFontSizes.Font15,
    fontFamily: AppFontFamilies.PingFangSC,
    fontWeight: FontWeight.w500,
  );

  final TextStyle _listTileTrailingStyle = TextStyle(
    color: AppColors.PlaceholderTextColor,
    fontSize: AppFontSizes.Font14,
    fontFamily: AppFontFamilies.PingFangSC,
    fontWeight: FontWeight.w500,
  );



  /// 时间区域
  Widget _dateSection({String date, String time}) {
    return Container(
      height: 18,
      child: Row(
        children: <Widget>[
          Text(
            date,
            style: TextStyle(
              color: AppColors.MainColor,
              fontSize: AppFontSizes.Font13,
              fontFamily: AppFontFamilies.PingFangSC,
              fontWeight: FontWeight.w500,
            ),
          ),
          Padding(padding: EdgeInsets.only(left: 12)),
          Expanded(
            child: Text(
              time,
              style: TextStyle(
                color: AppColors.MainColor,
                fontSize: AppFontSizes.Font13,
                fontFamily: AppFontFamilies.PingFangSC,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
        ],
      ),
    );
  }

  /// 内容文字
  Widget _contentSection({String content}) {
    return Text(
      content,
      style: TextStyle(
        color: AppColors.TextColor,
        fontSize: AppFontSizes.Font15,
        fontFamily: AppFontFamilies.PingFangSC,
        fontWeight: FontWeight.w500,
      ),
    );
  }

  Widget _addressSection({String address}) {
    return Container(
      height: 18,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            width: 16,
            height: 16,
            color: Colors.red,
          ),
          Padding(padding: EdgeInsets.only(left: 10)),
          Expanded(
            child: Text(
              address,
              style: TextStyle(
                color: AppColors.DetailTextColor,
                fontSize: AppFontSizes.Font13,
                fontFamily: AppFontFamilies.PingFangSC,
                fontWeight: FontWeight.w500,
              ),
              overflow: TextOverflow.ellipsis,
              maxLines: 1,
            ),
          ),
        ],
      ),
    );
  }

  Widget _companyNameSection({String companyName}) {
    return Container(
      height: 18,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            width: 16,
            height: 16,
            color: Colors.red,
          ),
          Padding(padding: EdgeInsets.only(left: 10)),
          Expanded(
            child: Text(
              companyName,
              style: TextStyle(
                color: AppColors.DetailTextColor,
                fontSize: AppFontSizes.Font13,
                fontFamily: AppFontFamilies.PingFangSC,
                fontWeight: FontWeight.w500,
              ),
              overflow: TextOverflow.ellipsis,
              maxLines: 1,
            ),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        title: Title,
        actions: <Widget>[
          MaterialButton(
            onPressed: () {},
            child: Text(
              '更多',
              style: AppStyles.actionsTitleStyle,
            ),
            splashColor: Colors.transparent,
            highlightColor: Colors.transparent,
          )
        ],
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Padding(padding: EdgeInsets.only(top: 10)),
            Container(
              color: Colors.white,
              padding: EdgeInsets.fromLTRB(16, 13, 16, 13),
              child: Column(
                children: <Widget>[
                  _dateSection(
                    date: '2017/6/22',
                    time: '14:30',
                  ),
                  Padding(padding: EdgeInsets.only(top: 13)),
                  _contentSection(
                    content: '因项目的技术原因进行拜访因项目的技术原因进行拜访因项目的技术原因进行拜访',
                  ),
                  Container(
                      // 图片区域
                      ),
                  Padding(padding: EdgeInsets.only(top: 25)),
                  _addressSection(address: '泉州市晋江市龙湖镇后宅村宗兴大厦'),
                  Padding(padding: EdgeInsets.only(top: 8)),
                  _companyNameSection(companyName: '信兴拉链'),
                ],
              ),
            ),
            Padding(padding: EdgeInsets.only(top: 10)),
            ListTileNormal(
              title: Text('拜访类型', style: _listTileTitleStyle),
              trailing: Text('定期拜访', style: _listTileTrailingStyle),
              arrowVisible: true,
            ),
            ListTileNormal(
              title: Text('拜访人', style: _listTileTitleStyle),
              trailing: Text('林剑飞', style: _listTileTrailingStyle),
              arrowVisible: true,
            )
          ],
        ),
      ),
    );
  }
}
